import axios from 'axios'
import cookie from '../../assets/js/cookie'
import dsktConstant from "../../config/constant";

export default {
	//登录接口
	login(reqData) {
		let param = new URLSearchParams();
		for (var key in reqData) {
			param.append(key, reqData[key])
		}
		return axios({
			url: '/basic/user/login',
	//		url: '/basic/user/staff/bind',
			method: 'post',
			data: param,
			headers: {
				'Content-Type': 'application/x-www-form-urlencoded'
			}
		});
	},
	staffBind(reqData) {
		let param = new URLSearchParams();
		for (var key in reqData) {
			param.append(key, reqData[key])
		}
		return axios({
	//		url: '/basic/user/login',
			url: '/basic/user/staff/bind',
			method: 'post',
			data: param,
			headers: {
				'Content-Type': 'application/x-www-form-urlencoded'
			}
		});
	},
	//登录接口
	stuBind(reqData) {
		let param = new URLSearchParams();
		for (var key in reqData) {
			param.append(key, reqData[key])
		}
		return axios({
			url: '/basic/user/student/bind',
			method: 'post',
			data: param,
			headers: {
				'Content-Type': 'application/x-www-form-urlencoded'
			}
		});
	},
	//登录接口
	openIdLogin(openId, sysNo) {
		let param = new URLSearchParams();
		param.append("openId", openId);
		param.append("sysNo", sysNo);
		return axios({
			url: '/basic/user/wechat',
			method: 'post',
			data: param,
			headers: {
				'Content-Type': 'application/x-www-form-urlencoded'
			}
		});
	},
	//获取用户分页
	getUesrPage(page, param) {
		var reqData = {
			page: page,
			params: param, //+'?'+ this.$qs.stringify(reqData)
			rows: 10
		};
		return axios({
			url: '/thridclassroom/student_check_in_bed/pageStudentBydormitory',
			method: 'post',
			data: reqData,
		});
	},
	//获取学生开单
	getStudentOpenOrder(userId) {
		return axios.get('/basic/empower/student/switch?studentUserId=' + userId + "&sysNo=" + dsktConstant.SYS_NO);
	},
	//获取用户分页
	getTeacherInfo(userId) {
		return axios.get('/basic/staff_file/' + userId);
	},
	//获取用户分页
	getStudentInfo(userId) {
		return axios.get('/basic/student_file/' + userId);
	},
	//GET /user/staff/no/{no}根据工号获取职工用户
	getTeaByNo(no) {
		return axios.get('/basic/user/staff/no/' + no);
	},
	//GET /user/student/{id}
	getStuById(id) {
		return axios.get('/basic/user/student/' + id);
	},
	//修改教师信息
	updateTeacherInfo(reqData) {
		return axios({
			url: '/basic/staff_file',
			method: 'put',
			data: reqData,
		});
	},
	//修改学生信息
	updateStudentInfo(reqData) {
		return axios({
			url: '/basic/student_file/edit',
			method: 'post',
			data: reqData,
		});
	},
	//修改学生入住图片
	updateStudentCheckInfo(img) {
		var reqData = {
			studentUserId: cookie.getUserId(),
			headImg: img,
			schoolId: cookie.get(cookie.key.schoolId)
		}

		let param = new URLSearchParams();
		for (var key in reqData) {
			param.append(key, reqData[key])
		}
		return axios({
			url: '/thridclassroom/student_check_in_bed/updateStudentImg',
			method: 'post',
			data: param,
			headers: {
			'Content-Type': 'application/x-www-form-urlencoded'
			}
		});
	},

	//根据宿舍号或者 床号查询
	selectableStudent(reqData) {
		var params = {
			page: 1,
			params: reqData, //+'?'+ this.$qs.stringify(reqData)
			rows: 1000
		}
			return axios({
			  url: '/thridclassroom/student_check_in_bed/pageStudentBydormitory',
			  method: 'post',
			  data: params,
			});
	/*   return axios({
	    url: '/thridclassroom/student_check_in_bed/selectable',
	    method: 'get',
	    params: reqData,
	  }); */
	},
}